/*
 * 功能: 使用apier插件
 * http://192.168.115.239/#/doc/guid/apier-beta
 */

import Vue from 'vue'
import store from '../store'
import Apier from '../assemblies/plugins/apier/apier'
import * as demo from './demo'

const options = {
  // 将demo文件夹下定义的所有api挂载到ui模块下
  modules: {
    ui: { ...demo }
  },

  timeout: 30000,

  authDetection: {
    enable: false
  },

  headers: {
    'X-Client-Id': window.$app.appId,
    'Branch_Code': window.$app.user.branchCode,
    'Tenant-Id': window.$app.user.branchCode,
    'Access-Token': window.$app.user.token,
    'X-User-Account': window.$app.user.userId,
    'Current-Org-Id': window.$app.user.orgId,
    'Role-Id': window.$app.user.role
  },

  baseUrl: window.$app.apiBaseUrl
}

// 在开发环境挂载demo实例
if (process.env.NODE_ENV === 'development') {
  options.modules.ui = { ...demo }
}

const apier = new Apier(store, options)
Vue.use(Apier, apier)

export default apier
